﻿'********************************************************************************
'*
'*      マスタ履歴　フォーム
'*
'*      File Name : frmStartCompleteDB.vb
'*      Title     : DB着工/完了履歴画面
'*      機能    　：DB着工/完了履歴
'*
'********************************************************************************
'----------------------------------<<修正履歴>>----------------------------------
'ﾊﾞｰｼﾞｮﾝ   日付       作業者        ｺﾒﾝﾄ
'--------- ---------- ------------ -----------------------------------------------
' V1.0.0   2016/07/11 S.Yu         新規作成
' V2.0.0   2017/04/18 T.Yutaro     蘇州対応
' V3.0.0   2017/12/12 M.Ohga       北京対応
' V4.0.0   2018/01/05 miao　　　　 北京対応臨時案（フレームID管理を判定しなく、計上する）
'********************************************************************************

Imports System.Web.UI.WebControls.Expressions

Public Class frmStartCompleteDB


    Private SetBsiteFrameFLG As Boolean = False
    ' b-Site取得カテゴリーとの比較文字列
    Private Const BSITE_CATEGORY_FRAME As String = "DBLF"
    Private Const BSITE_CATEGORY_PASTE As String = "DBPS"

    ' 前工程ウェハケースNo保持
    Dim preWaferCaseNo As String

    ' 外部画面呼び出しTAG
    Private Const EXEC_PG_TAG_FRAME As String = "DB_FRAME"
    Private Const EXEC_PG_TAG_ATLAS As String = "DB_ATLAS"
    Private Const EXEC_PG_TAG_PASTE As String = "DB_PASTE"

    Private Const DP_CNT As String = "DP CNT"
    Private strDP_CNT As String = "0" 'ADD 苗 2018/1/25 既定値"0"を設定


    '>>2018/2/13 大賀 サンプル数量対応
    Private AggregatePKG As String = String.Empty
    '>>2018/2/13 大賀 サンプル数量対応

    '>>2018/1/31 佐川 キャリア交換対応
    '実行モード
    '0:表示 1:着工 2:製造完成 3:計上完成
    Private execMode As String = VIEW

    Private dtLot As DataTable


    'Add Miaojf 2019/11/22 Begin
    Overrides Sub selectTab()

        tabBase.SelectedIndex = 2

        Me.UpdateStyles()
    End Sub
    'Public Overrides Sub SetFocus()

    '    btnBarCodeWafer.Enabled = True
    '    btnBarCodeWafer.PerformClick()
    '    'txt0002.Enabled = True
    '    'txt0002.Focus()
    'End Sub
    'Add Miaojf 2019/11/22 END

    '<<2018/1/31 佐川 キャリア交換対応

    ' 着工前チェック項目：ペースト1,2 フレーム1,2,3 ウェハケースNo
    Enum SCORE_NUM As Integer
        PASTE1
        PASTE2
        FRAME1
        FRAME2
        FRAME3
        WAFERCASE
    End Enum
    '照合結果設定

    Private WTKEYNOHT As New Hashtable

    Public Overrides Sub SetPassScore()
        PASS_SCORE = 6
        ReDim m_iScore(PASS_SCORE - 1)
        m_iScore = {PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK}
    End Sub

    '照合結果をクリアする
    Public Overrides Sub InitualizeCollData()
        m_iScore = {PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK}
    End Sub

    'イベント設定
    Public Overrides Sub SetHandler()
        '画面初期化
        inputDataClear()

        ' 設備タブ
        '再読込ボタン
        AddHandler btnRefresh.Click, AddressOf btnRefresh_Click
        'フレーム補充ボタン
        AddHandler btnFrameAdd.Click, AddressOf btnFrameAdd_Click
        'ペースト補充ボタン
        AddHandler btnPasteAdd.Click, AddressOf btnPasteAdd_Click

        ' 情報タブ
        'ウェハケースNo
        AddHandler btnBarCodeWafer.Click, AddressOf btnBeforeRackNo_Click ' 2018/2/22 佐川 ラックNo入力動作を統一
        AddHandler txt0903.KeyPress, AddressOf WaferTxtData_KeyPress ' 2018/2/22 佐川 ラックNo入力動作を統一
        'AddHandler txt0903.LostFocus, AddressOf WaferTxtData_LostFocus

        ' ラックNo
        AddHandler btnBarCodeRack.Click, AddressOf btnRackNo_Click
        AddHandler txt1002.KeyPress, AddressOf txtRackNoDB_KeyPress
        AddHandler txt1003.KeyPress, AddressOf txtRackNoDB_KeyPress
        AddHandler txt1004.KeyPress, AddressOf txtRackNoDB_KeyPress
        AddHandler txt1005.KeyPress, AddressOf txtRackNoDB_KeyPress
        AddHandler txt1006.KeyPress, AddressOf txtRackNoDB_KeyPress
        AddHandler txt1002.LostFocus, AddressOf txtRackNo_LostFocus
        AddHandler txt1003.LostFocus, AddressOf txtRackNo_LostFocus
        AddHandler txt1004.LostFocus, AddressOf txtRackNo_LostFocus
        AddHandler txt1005.LostFocus, AddressOf txtRackNo_LostFocus
        AddHandler txt1006.LostFocus, AddressOf txtRackNo_LostFocus

        ' 空芯片数量
        AddHandler lblEmptyChips.Click, AddressOf TenKeyClick
        ' 扔芯片数量
        AddHandler lblThrowChips.Click, AddressOf TenKeyClick

        ' >> 20180710 佐川 ラックNo途入力改善
        AddHandler lbl1002.Click, AddressOf rackInputFocus
        AddHandler txt1002.Click, AddressOf rackInputFocus
        AddHandler lbl1003.Click, AddressOf rackInputFocus
        AddHandler txt1003.Click, AddressOf rackInputFocus
        AddHandler lbl1004.Click, AddressOf rackInputFocus
        AddHandler txt1004.Click, AddressOf rackInputFocus
        AddHandler lbl1005.Click, AddressOf rackInputFocus
        AddHandler txt1005.Click, AddressOf rackInputFocus
        AddHandler lbl1006.Click, AddressOf rackInputFocus
        AddHandler txt1006.Click, AddressOf rackInputFocus
        ' >> 20180710 佐川 ラックNo途入力改善

        MyBase.lblEmptyChipsCnt = Me.lblEmptyChips

    End Sub

    ' 製造完成時のチェック(必要な画面のみ)
    Protected Overrides Function ManufCompCheck() As Boolean
        Debug.WriteLine(System.Reflection.MethodBase.GetCurrentMethod.Name + " in")
        Return True
    End Function
    'DEL 苗 2018/1/5 臨時案（フレームID管理を判定しなく、計上する）BEGIN
    '' 計上完成時にATLAS画面を呼び出すかチェック(必要な画面のみ)
    'Protected Overrides Function isCompleteCallAtlas() As Boolean
    '    Debug.WriteLine(System.Reflection.MethodBase.GetCurrentMethod.Name + " in")
    '    ' 呼び出しが必要
    '    Return True
    'End Function

    '' 計上完成時にATLAS画面を呼び出す処理
    'Protected Overrides Function CallAtlasExec() As Boolean
    '    Debug.WriteLine(System.Reflection.MethodBase.GetCurrentMethod.Name + " in")
    '    Dim ret = True
    '    '外部EXEを呼び出す
    '    Dim strRetStatus As String = Execute_Command(lblProcessCD.Text, EXEC_PG_TAG_ATLAS)
    '    If strRetStatus = "0" Then
    '        ret = True
    '    Else
    '        MsgBox(getMsgStr("MSG10009", strRetStatus))
    '        ret = False
    '    End If
    '    '戻り値による処理は未定のため、現在は未実装
    '    Return ret
    'End Function
    'DEL 苗 2018/1/5 臨時案（フレームID管理を判定しなく、計上する）END
    'Lot Noでデータベースからデータを取得する
    Public Overrides Sub GetDataByIcTag()
        Debug.WriteLine(System.Reflection.MethodBase.GetCurrentMethod.Name + " in")
        m_RackWidthCheck = 1 'ADD 苗 2018/1/27 ラック桁数チェック
        'ICタグのデータで画面を設定する
        inputDataClear()
        SetFromTag()
        If m_MoveInCheck = False Then Exit Sub
        setGridViewLot()

        '>>20171202 兪
        lblPcbCnt.Text = String.Empty
        '<<20171202 兪

        PasteTimer.Enabled = False

        If String.IsNullOrEmpty(IcTag.szUID) Then
            IcTag = LastTag
        End If

        '製造条件
        setJyokenData()

        For Each dr In dtJyokenData.Rows
            If dr("KOMOKUNAME").Equals(lbl0100.Tag) Then
                'ペースト
                lbl0102.Text = dr("KOMOKUDATA")
            ElseIf dr("KOMOKUNAME").Equals(lbl0200.Tag) Then
                'フレーム
                lbl0202.Text = dr("KOMOKUDATA")
                'ADD 苗 2018/1/11 BEGIN
            ElseIf dr("KOMOKUNAME").Equals(DP_CNT) Then
                If dr("KOMOKUDATA") <> "" Then
                    strDP_CNT = dr("KOMOKUDATA")
                Else
                    strDP_CNT = "0"
                End If
                'ADD 苗 2018/1/11 END
                '>>2018/2/13 大賀 サンプル数量対応
            ElseIf dr("KOMOKUNAME").Equals(AGGREGATE_PKG) Then
                AggregatePKG = dr("KOMOKUDATA")
                '<<2018/2/13 大賀 サンプル数量対応
            End If
        Next

        strDP_CNT = m_cData.getDTCount(IcTag.szLotNo)

        '>>2018/1/31 佐川 キャリア交換対応
        preWaferCaseNo = IcTag.container1
        '前工程情報取得、設定
        'For Each drPreDetail In dtPreDetailData.Rows
        '    If drPreDetail(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG).Equals(lbl0900.Tag) Then
        '        '前工程ウェハケースNo
        '        preWaferCaseNo = drPreDetail(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL)
        '    End If
        'Next
        '<<2018/1/31 佐川 キャリア交換対応
        'ADD 苗 2018/1/29 BEGIN
        If AutoManualMode = 0 And m_cEquipMat.isWaferCaseChecked(IcTag.szProcsCD, IcTag.szLotNo) Then
            txt0903.Text = preWaferCaseNo
            m_iScore(SCORE_NUM.WAFERCASE) = PASS_SCORE_CHECKED
        End If
        'ADD 苗 2018/1/29 END

        '現物型式
        setDetailData()
        For Each dr In dtDetailData.Rows
            If DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG)).Equals(lbl0100.Tag) Then
                ' ペースト
                If DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_SEQ)) = 1 Then
                    txt0103.Text = DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL))
                    txt0104.Text = DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_MATERIAL_LOT))
                    lbl0106.Text = DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_LIMIT_TIME))
                    'DEL 苗 2018/1/30 BEGIN 材料１だけの対応
                    'ElseIf dr(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 2 Then
                    '    txt0203.Text = dr(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL)
                    '    txt0204.Text = dr(DB_WORK_RESULT_PHYSICALNAME_MATERIAL_LOT)
                    '    lbl0206.Text = dr(DB_WORK_RESULT_PHYSICALNAME_LIMIT_TIME)
                    'DEL 苗 2018/1/30 END 材料１だけの対応
                End If
            ElseIf DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG)).Equals(lbl0200.Tag) Then
                ' フレーム
                If DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_SEQ)) = 1 Then
                    txt0303.Text = DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL))
                End If
                'ADD 苗 2018/1/30 BEGIN フレームのメーカーロット
                ' フレーム
                If DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_SEQ)) = 1 Then
                    txt0304.Text = DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_MATERIAL_LOT))
                End If
                'ADD 苗 2018/1/30 ENDフレームのメーカーロット

            ElseIf DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG)).Equals(lbl0900.Tag) Then
                'ウェハケースNo
                txt0903.Text = DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL))
            ElseIf DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG).Equals(lbl1000.Tag)) Then
                'ラックNo
                If DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_SEQ)) = 1 Then
                    txt1002.Text = DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL))
                ElseIf DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_SEQ)) = 2 Then
                    txt1003.Text = DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL))
                ElseIf DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_SEQ)) = 3 Then
                    txt1004.Text = DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL))
                ElseIf DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_SEQ)) = 4 Then
                    txt1005.Text = DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL))
                ElseIf DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_SEQ)) = 5 Then
                    txt1006.Text = DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL))
                End If
            ElseIf DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG)).Equals(lblTitleEmptyChips.Tag) Then
                lblEmptyChips.Text = DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL))
            ElseIf DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG)).Equals(lblTitleThrowChips.Tag) Then
                lblThrowChips.Text = dr(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL)
            ElseIf DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG)).Equals(lblTitleExcess.Tag) Then
                lblExcess.Text = DBNullTOblank(dr(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL))
            End If
        Next

        '>>2018/2/13 大賀 サンプル数量対応
        If IcTag.Status = TagProcessStatus.Ready Then
            lblSampleText.Text = m_cSamplingDef.getSamplingMessage(IcTag.szProcsCD, AggregatePKG)
        Else
            Dim getData = dtDetailData.AsEnumerable().FirstOrDefault(Function(x) lblSampleTitle.Tag.Equals(x("MNF_CND_TAG")))
            If getData IsNot Nothing Then
                lblSampleText.Text = getData("ACTUAL_MODEL")
            End If
        End If
        '<<2018/2/13 大賀 サンプル数量対応

        getHeadData()

        With m_dtMat
            If .Rows.Count > 0 Then
                '着完日時
                DisplayDate()
            Else
                If m_dtMat.Columns.Count > 0 Then
                    .Rows.Add()
                Else
                    .Columns.Add("BEGIN_TIME")
                    .Rows.Add()
                End If
            End If
        End With

        ' 着工中の場合は，ペーストのタイマーをスタートさせる
        If IcTag.Status <> TagProcessStatus.Ready Then
            PasteTimer.Enabled = True
        End If

        ' 着工前の場合はb-Site連携を行う
        If IcTag.Status = TagProcessStatus.Ready Then
            getBsiteData()
        End If
        RandCheckFLAG = True
    End Sub

    '画面データ保存（着工時）
    Public Overrides Function SaveEquipMat(ByRef szBeginTime As DateTime) As Boolean

        '>>2018/1/31 佐川 キャリア交換対応
        execMode = BEGIN
        '<<2018/1/31 佐川 キャリア交換対応

        If saveDetail(BEGIN) < 0 Then
            Return False
        Else
            Return True
        End If
    End Function

    '画面データ保存（製造完成）
    Public Overrides Function SaveCompleteInfo(Optional ByVal status As ProcessStatus = ProcessStatus.ManufComplete) As Integer

        '>>2018/1/31 佐川 キャリア交換対応
        execMode = COMPLETE
        '<<2018/1/31 佐川 キャリア交換対応

        dtDBUpd.Clear()
        Return saveDetail(COMPLETE)
    End Function

    '画面データ保存（計上完成）
    Public Overrides Function SaveTotalInfo() As Integer

        '>>2018/1/31 佐川 キャリア交換対応
        execMode = TOTAL
        '<<2018/1/30 佐川 キャリア交換対応

        dtDBUpd.Clear()
        Return saveDetail(TOTAL)
    End Function

    '工程明細テーブル更新処理
    Private Function saveDetail(ByVal type As String) As Integer
        setLotData()
        Dim rowsCnt As Integer = dtDBUpd.Rows.Count
        Dim addIndex As Integer = 0

        ' ペースト
        dtDBUpd.Rows.Add()
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = lbl0100.Tag
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = CND_TAG_FLG_JYOKEN
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 1
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CONDITION) = lbl0102.Text
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = txt0103.Text
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MATERIAL_LOT) = txt0104.Text
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_LIMIT_TIME) = lbl0106.Text
        addIndex += 1

        ' フレーム
        dtDBUpd.Rows.Add()
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = lbl0200.Tag
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = CND_TAG_FLG_JYOKEN
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 1
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CONDITION) = lbl0202.Text
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = txt0303.Text
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MATERIAL_LOT) = txt0304.Text 'ADD 苗 2018/1/30 フレームのメーカーロット
        addIndex += 1

        ' ウェハケースNo
        dtDBUpd.Rows.Add()
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = lbl0900.Tag
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = CND_TAG_FLG_ELSE
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 1
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = txt0903.Text
        addIndex += 1

        If type <> BEGIN Then
            ' ラックNo
            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = lbl1000.Tag
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = CND_TAG_FLG_ELSE
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 1
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = txt1002.Text
            addIndex += 1

            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = lbl1000.Tag
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = CND_TAG_FLG_ELSE
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 2
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = txt1003.Text
            addIndex += 1

            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = lbl1000.Tag
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = CND_TAG_FLG_ELSE
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 3
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = txt1004.Text
            addIndex += 1

            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = lbl1000.Tag
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = CND_TAG_FLG_ELSE
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 4
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = txt1005.Text
            addIndex += 1

            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = lbl1000.Tag
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = CND_TAG_FLG_ELSE
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 5
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = txt1006.Text
            addIndex += 1

            '空芯片数量
            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = lblTitleEmptyChips.Tag
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = CND_TAG_FLG_ELSE
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 1
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = lblEmptyChips.Text
            addIndex += 1

            '扔芯片数量
            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = lblTitleThrowChips.Tag
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = CND_TAG_FLG_ELSE
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 1
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = lblThrowChips.Text
            addIndex += 1

            '過不足
            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = lblTitleExcess.Tag
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = CND_TAG_FLG_ELSE
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 1
            dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = lblExcess.Text
            addIndex += 1
        End If
        '>>2018/2/13 大賀 サンプル数量対応
        'サンプル数量
        dtDBUpd.Rows.Add()
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = lblSampleTitle.Tag
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = CND_TAG_FLG_ELSE
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 1
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = lblSampleText.Text
        addIndex += 1
        '<<2018/2/13 大賀 サンプル数量対応

        Return m_cEquipMat.SaveDetail(lotNo, IcTag.szProcsCD, type,
                                      m_szTable, dtDBUpd, m_dtHeader,
                                      m_cIdohyo.EquipInfo.szEquipNo, serverTime)
    End Function

    '計上完成時チェック処理
    Public Overrides Function EndCheck() As Boolean

        ' 設備タブのチェック
        '>>2018/2/20 大賀 No79 計上完成時にBSiteチェック実施
        '' ペースト製造条件1行目
        'If String.IsNullOrEmpty(txt0103.Text) Then
        '    MsgBox(getMsgStr("MSG00101", lbl0100.Text))
        '    Return False
        'ElseIf txt0103.Text <> lbl0102.Text Then
        '    MsgBox(getMsgStr("MSG00021", lbl0100.Text))
        '    txt0103.BackColor = ERROR_INIT_COLOR
        '    Return False
        'End If
        'DEL 苗 2018/1/30 BEGIN 材料１だけの対応
        '' ペースト製造条件2行目
        'If Not String.IsNullOrEmpty(txt0203.Text) Then
        '    If txt0203.Text <> lbl0102.Text Then
        '        MsgBox(getMsgStr("MSG00021", lbl0100.Text))
        '        txt0203.BackColor = ERROR_INIT_COLOR
        '        Return False
        '    End If
        'End If
        'DEL 苗 2018/1/30 END 材料１だけの対応
        '' ペースト使用期限1行目
        'If String.IsNullOrEmpty(lbl0106.Text) Then
        '    MsgBox(getMsgStr("MSG00101", lbl0100.Text))
        '    Return False
        'ElseIf Not checkExpirationDate(lbl0106, 0) Then
        '    Return False
        'End If
        'DEL 苗 2018/1/30 BEGIN 材料１だけの対応
        '' ペースト使用期限2行目
        'If Not String.IsNullOrEmpty(lbl0206.Text) Then
        '    If Not checkExpirationDate(lbl0206, 1) Then
        '        Return False
        '    End If
        'End If
        'DEL 苗 2018/1/30 END 材料１だけの対応
        '' フレーム製造条件1行目
        'If String.IsNullOrEmpty(txt0303.Text) Then
        '    MsgBox(getMsgStr("MSG00101", lbl0200.Text))
        '    Return False
        'ElseIf txt0303.Text <> lbl0202.Text Then
        '    MsgBox(getMsgStr("MSG00021", lbl0200.Text))
        '    txt0303.BackColor = ERROR_INIT_COLOR
        '    Return False
        'End If
        '' フレーム製造条件2行目
        'If Not String.IsNullOrEmpty(txt0403.Text) Then
        '    If txt0403.Text <> lbl0202.Text Then
        '        MsgBox(getMsgStr("MSG00021", lbl0200.Text))
        '        txt0403.BackColor = ERROR_INIT_COLOR
        '        Return False
        '    End If
        'End If
        '' フレーム製造条件3行目
        'If Not String.IsNullOrEmpty(txt0503.Text) Then
        '    If txt0503.Text <> lbl0202.Text Then
        '        MsgBox(getMsgStr("MSG00021", lbl0200.Text))
        '        txt0503.BackColor = ERROR_INIT_COLOR
        '        Return False
        '    End If
        'End If
        If Not getBsiteData() Then
            PutLog(Me.ToString, "getBsiteData", "getBsiteData false")
            Return False
        End If
        '<<2018/2/20 大賀 No79 計上完成時にBSiteチェック実施

        'ADD 苗 2018/1/18 BEGIN
        If String.IsNullOrEmpty(txt1002.Text) And String.IsNullOrEmpty(txt1003.Text) And
           String.IsNullOrEmpty(txt1004.Text) And String.IsNullOrEmpty(txt1005.Text) And
         String.IsNullOrEmpty(txt1006.Text) Then
            PutLog(Me.ToString, "NULL CHECK", getMsgStr("MSG00002", lbl1000.Text))
            MsgBox(getMsgStr("MSG00002", lbl1000.Text))
            Return False
        End If
        'ADD 苗 2018/1/18 END


        '空芯片数量の空白チェック
        If Not checkBlank(lblEmptyChips.Text, lblTitleEmptyChips.Text) Then
            PutLog(Me.ToString, "空芯片数量", "空芯片数量の空白")
            lblEmptyChips.BackColor = ERROR_INIT_COLOR
            Return False
        End If

        '扔芯片数量の空白チェック
        If Not checkBlank(lblThrowChips.Text, lblTitleThrowChips.Text) Then
            PutLog(Me.ToString, "扔芯片数量", "扔芯片数量の空白")
            lblThrowChips.BackColor = ERROR_INIT_COLOR
            Return False
        End If

        'ラックNo1の空白チェック
        If Not checkBlank(txt1002.Text, lbl1000.Text) Then
            PutLog(Me.ToString, "ラックNo1の空白", "ラックNo1の空白")
            txt1002.BackColor = ERROR_INIT_COLOR
            lbl1002.BackColor = ERROR_INIT_COLOR
            Return False
        End If

        setXInnNum() 'ADD 苗 2018/1/5

        '抜取り検査は未実行であれば、計上しない
        Dim objRCHistory As New clsRandCheckHistory
        Dim dtRCHistory As DataTable
        dtRCHistory = objRCHistory.selectRandCheckHistory(IcTag.szLotNo, IcTag.szProcsCD, lblEquipID.Text, "", "")
        If IsNothing(dtRCHistory) = False AndAlso dtRCHistory.Rows.Count <> 0 Then
            If DBNullTOblank(dtRCHistory.Rows(0)("STATUS")) = "" Then
                PutLog(Me.ToString, "EndCheck", "err:frmRandomInspection")

                'MsgBox(getMsgStr("MSG10053"))
                Dim frm1 As New frmRandomInspection
                '抜け取り検査画面を呼出
                frm1.ShowDialog()
                MsgBox(getMsgStr("MSG00117", "请再次进行 计上完成 。"))
                Return False
            End If
        End If

        Return True
    End Function

    ''ウェハケースNo バーコード入力LostFocus時の照合チェック
    'Private Sub WaferTxtData_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs)
    '    '>> 2018/2/22 佐川 ラックNo入力動作を統一
    '    RemoveHandler txt0903.LostFocus, AddressOf WaferTxtData_LostFocus

    '    'ウェハケースNoの空白チェック
    '    Dim title As String = lbl0900.Text.Replace(Environment.NewLine, "")
    '    If Not checkBlank(txt0903.Text, title) Then
    '        txt0903.BackColor = ERROR_INIT_COLOR
    '        lbl0903.BackColor = ERROR_INIT_COLOR
    '        txt0903.Focus()
    '        txt0903.SelectAll()
    '        m_iScore(SCORE_NUM.WAFERCASE) = PASS_SCORE_WAIT_CHECK
    '        '前工程一致チェック
    '    ElseIf preWaferCaseNo <> txt0903.Text Then
    '        MsgBox(getMsgStr("MSG00093", lbl0900.Text, txt0903.Text))
    '        txt0903.BackColor = ERROR_INIT_COLOR
    '        lbl0903.BackColor = ERROR_INIT_COLOR
    '        txt0903.Focus()
    '        txt0903.SelectAll()
    '        m_iScore(SCORE_NUM.WAFERCASE) = PASS_SCORE_WAIT_CHECK
    '        '>>20180313 大賀 搬送容器桁数チェックを共通化
    '        ' ウェハケースNoの桁数チェック
    '    ElseIf Not isCheckCaseLength(txt0903, WAFER_CASE_NO_LENGTH, lbl0903) Then
    '        m_iScore(SCORE_NUM.WAFERCASE) = PASS_SCORE_WAIT_CHECK
    '        '<<20180313 大賀 搬送容器桁数チェックを共通化
    '    Else
    '        txt0903.Enabled = False
    '        txt0903.BackColor = ENTERED_INIT_COLOR
    '        lbl0903.BackColor = ENTERED_INIT_COLOR
    '        m_iScore(SCORE_NUM.WAFERCASE) = PASS_SCORE_CHECKED
    '        CheckCollScore()
    '    End If

    '    AddHandler txt0903.LostFocus, AddressOf WaferTxtData_LostFocus
    '    '<< 2018/2/22 佐川 ラックNo入力動作を統一

    '    'Add 苗 2019/11/24 Begin
    '    Dim tmpLotNo As String
    '    tmpLotNo = m_cLotDefect.GetLotNoByRack(txt0903.Text)
    '    If (txtLotNo.Text = "" And tmpLotNo <> "") Or (tmpLotNo <> "" And txtLotNo.Text <> tmpLotNo) Then
    '        txtLotNo.Text = tmpLotNo
    '        If txtLotNo.Text.Trim() <> "" Then
    '            txtLotNo_KeyPress(txtLotNo, New KeyPressEventArgs(vbCr))

    '            Exit Sub
    '        End If
    '    End If
    '    'Add 苗 2019/11/24 End

    'End Sub

    '着工中になったらペーストのタイマーをスタートさせる
    Public Overrides Sub JiSuccess()
        MyBase.JiSuccess()
        'lblPcbCnt.Text = String.Empty 'ADD 苗 2018/1/13 
        PasteTimer.Enabled = True
        '>> 2018/02/14 佐川 過不足計算
        setXInnNum()
        '<< 2018/02/14 佐川 過不足計算
    End Sub

    ' ペースト使用期限のタイマー処理
    Private Sub PasteTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles PasteTimer.Tick
        PasteTimer.Enabled = False
        If Not IcTag.Status <> TagProcessStatus.Ready Then
            ' 着工中でない場合，タイマーをストップする
            Exit Sub
        End If

        ' ペースト1行目
        'If Not String.IsNullOrEmpty(lbl0106.Text) Then
        '    If Not checkExpirationDate(lbl0106, 0) Then
        '        Exit Sub
        '    End If
        'End If
        'DEL 苗 2018/1/30 BEGIN 材料１だけの対応
        '' ペースト2行目
        'If Not String.IsNullOrEmpty(lbl0206.Text) Then
        '    If Not checkExpirationDate(lbl0206, 1) Then
        '        Exit Sub
        '    End If
        'End If
        'DEL 苗 2018/1/30 END 材料１だけの対応
        PasteTimer.Enabled = True
    End Sub

    Private Sub inputDataClear()
        Debug.WriteLine(System.Reflection.MethodBase.GetCurrentMethod.Name + " in")

        '>>2018/1/30 佐川 キャリア交換対応
        execMode = VIEW
        '<<2018/1/30 佐川 キャリア交換対応

        'LOTタブクリア
        clearActualModel()

        '設備タブ 再読込ボタン
        btnRefresh.Enabled = False
        '設備タブ 補充ボタン
        btnFrameAdd.Enabled = False
        '設備タブ ペースト補充ボタン
        btnPasteAdd.Enabled = False
        '情報タブ ウェハケースNoバーコードボタン
        btnBarCodeWafer.Enabled = False
        '情報タブ ラックNoバーコードボタン
        btnBarCodeRack.Enabled = False
        lblEmptyChips.Enabled = False
        lblThrowChips.Enabled = False

        'ペースト
        initPasteParams(True)

        'フレーム
        initFrameParams(True)

        'ウェハケースNo
        txt0903.Text = String.Empty
        txt0903.BackColor = NORMAL_INIT_COLOR
        lbl0903.BackColor = NORMAL_INIT_COLOR

        'ラックNo1
        txt1002.Text = String.Empty
        txt1002.BackColor = NORMAL_INIT_COLOR
        lbl1002.BackColor = NORMAL_INIT_COLOR

        'ラックNo2
        txt1003.Text = String.Empty
        txt1003.BackColor = NORMAL_INIT_COLOR
        lbl1003.BackColor = NORMAL_INIT_COLOR

        'ラックNo3
        txt1004.Text = String.Empty
        txt1004.BackColor = NORMAL_INIT_COLOR
        lbl1004.BackColor = NORMAL_INIT_COLOR

        'ラックNo4
        txt1005.Text = String.Empty
        txt1005.BackColor = NORMAL_INIT_COLOR
        lbl1005.BackColor = NORMAL_INIT_COLOR

        'ラックNo5
        txt1006.Text = String.Empty
        txt1006.BackColor = NORMAL_INIT_COLOR
        lbl1006.BackColor = NORMAL_INIT_COLOR

        '空芯片数量
        lblEmptyChips.Text = 0
        lblEmptyChips.BackColor = NORMAL_INIT_COLOR

        '扔芯片数量
        lblThrowChips.Text = 0
        lblThrowChips.BackColor = NORMAL_INIT_COLOR

        '過不足
        lblExcess.BackColor = NORMAL_INIT_COLOR

        '開始作業者No
        txtOptNoStt.Text = String.Empty
        '終了作業者No
        txtOptNoEnd.Text = String.Empty

        '>>2018/2/15 大賀 サンプル数量対応 計上完成後のクリア漏れ
        lblSampleText.Text = String.Empty
        '<<2018/2/15 大賀 サンプル数量対応 計上完成後のクリア漏れ

    End Sub

    Public Overrides Sub ConfScreenItem()
        Debug.WriteLine(System.Reflection.MethodBase.GetCurrentMethod.Name + " in")

        If txtLotNo.TextLength > 0 Then
            If IcTag.Status = TagProcessStatus.Ready Then
                '着工待ち
                '設備タブ 再読込ボタン
                btnRefresh.Enabled = True
                '設備タブ 補充ボタン
                btnFrameAdd.Enabled = True
                '設備タブ ペースト補充ボタン
                btnPasteAdd.Enabled = True
                '情報タブ ウェハケースNoバーコードボタン
                btnBarCodeWafer.Enabled = True
                '情報タブ ラックNoバーコードボタン
                btnBarCodeRack.Enabled = False
                lblEmptyChips.Enabled = False
                lblThrowChips.Enabled = False

                ' 共通部　製造完成ボタン
                btnManufComp.Enabled = False
                ' 共通部　計上完成ボタン
                btnTotalComp.Enabled = False

                'ペースト
                initPasteParams(False)

                'フレーム
                initFrameParams(False)

                'ウェハケースNo
                txt0903.BackColor = BARCODE_INIT_COLOR
                lbl0903.BackColor = BARCODE_INIT_COLOR

                'ラックNo
                txt1002.BackColor = NORMAL_INIT_COLOR
                lbl1002.BackColor = NORMAL_INIT_COLOR
                txt1003.BackColor = NORMAL_INIT_COLOR
                lbl1003.BackColor = NORMAL_INIT_COLOR
                txt1004.BackColor = NORMAL_INIT_COLOR
                lbl1004.BackColor = NORMAL_INIT_COLOR
                txt1005.BackColor = NORMAL_INIT_COLOR
                lbl1005.BackColor = NORMAL_INIT_COLOR
                txt1006.BackColor = NORMAL_INIT_COLOR
                lbl1006.BackColor = NORMAL_INIT_COLOR

                '空芯片数量
                lblEmptyChips.BackColor = NORMAL_INIT_COLOR

                '扔芯片数量
                lblThrowChips.BackColor = NORMAL_INIT_COLOR

                'フレーム数自動計算：前工程完成数÷FrameのIC個数　値が切り上げで計上
                If strDP_CNT.Equals("0") = False Then
                    lblPcbCnt.Text = Math.Ceiling(IcTag.iInput / CInt(strDP_CNT))
                End If

            ElseIf IcTag.Status = TagProcessStatus.Processing Then
                '着工中
                '設備タブ 再読込ボタン
                btnRefresh.Enabled = True
                '設備タブ 補充ボタン
                btnFrameAdd.Enabled = True
                '設備タブ ペースト補充ボタン
                btnPasteAdd.Enabled = True
                '情報タブ ウェハケースNoバーコードボタン
                btnBarCodeWafer.Enabled = False
                '情報タブ ラックNoバーコードボタン
                btnBarCodeRack.Enabled = True
                lblEmptyChips.Enabled = True
                lblThrowChips.Enabled = True

                ' 共通部　製造完成ボタン
                btnManufComp.Enabled = False
                ' 共通部　計上完成ボタン
                btnTotalComp.Enabled = True 'UPD 苗 2018/1/10 計上ボタン⇒使える



                'ペースト
                initPasteParams(False)

                'フレーム
                initFrameParams(False)

                'ウェハケースNo
                txt0903.BackColor = NORMAL_INIT_COLOR
                lbl0903.BackColor = NORMAL_INIT_COLOR

                'ラックNo
                txt1002.BackColor = TENKEY_INIT_COLOR
                lbl1002.BackColor = TENKEY_INIT_COLOR
                txt1003.BackColor = TENKEY_INIT_COLOR
                lbl1003.BackColor = TENKEY_INIT_COLOR
                txt1004.BackColor = TENKEY_INIT_COLOR
                lbl1004.BackColor = TENKEY_INIT_COLOR
                txt1005.BackColor = TENKEY_INIT_COLOR
                lbl1005.BackColor = TENKEY_INIT_COLOR
                txt1006.BackColor = TENKEY_INIT_COLOR
                lbl1006.BackColor = TENKEY_INIT_COLOR

                '空芯片数量
                lblEmptyChips.BackColor = TENKEY_INIT_COLOR

                '扔芯片数量
                lblThrowChips.BackColor = TENKEY_INIT_COLOR

                'ADD 苗 2018/1/13 Begin
                'フレーム数自動計算：前工程完成数÷FrameのIC個数　値が切り上げで計上
                If strDP_CNT.Equals("0") = False Then
                    lblPcbCnt.Text = Math.Ceiling(IcTag.iInput / CInt(strDP_CNT))
                End If
                'ADD 苗 2018/1/13 END

            ElseIf IcTag.Status = TagProcessStatus.ManufComplete Then
                ' 製造完成
                '設備タブ 再読込ボタン
                btnRefresh.Enabled = True
                '設備タブ 補充ボタン
                btnFrameAdd.Enabled = True
                '情報タブ ウェハケースNoバーコードボタン
                btnBarCodeWafer.Enabled = False
                '情報タブ ラックNoバーコードボタン
                btnBarCodeRack.Enabled = True
                lblEmptyChips.Enabled = True
                lblThrowChips.Enabled = True

                ' 共通部　製造完成ボタン
                btnManufComp.Enabled = False
                ' 共通部　計上完成ボタン
                btnTotalComp.Enabled = True
                'ペースト
                initPasteParams(False)

                'フレーム
                initFrameParams(False)

                'ウェハケースNo
                txt0903.BackColor = NORMAL_INIT_COLOR
                lbl0903.BackColor = NORMAL_INIT_COLOR

                'ラックNo
                txt1002.BackColor = TENKEY_INIT_COLOR
                lbl1002.BackColor = TENKEY_INIT_COLOR
                txt1003.BackColor = TENKEY_INIT_COLOR
                lbl1003.BackColor = TENKEY_INIT_COLOR
                txt1004.BackColor = TENKEY_INIT_COLOR
                lbl1004.BackColor = TENKEY_INIT_COLOR
                txt1005.BackColor = TENKEY_INIT_COLOR
                lbl1005.BackColor = TENKEY_INIT_COLOR
                txt1006.BackColor = TENKEY_INIT_COLOR
                lbl1006.BackColor = TENKEY_INIT_COLOR

                '空芯片数量
                lblEmptyChips.BackColor = TENKEY_INIT_COLOR

                '扔芯片数量
                lblThrowChips.BackColor = TENKEY_INIT_COLOR

                setXInnNum() 'ADD 苗 2018/1/5
            Else
                '不正
                MsgBox(getMsgStr("MSG00025"))
            End If
        End If
    End Sub

    'B-Siteチェック
    Private Function getBsiteData() As Boolean
        'B-Site ViewMachineService
        Dim clientProcCd = GetBsiteClientString()


        Dim outMachine = getViewLotService(clientProcCd)

        If SetBsiteFrameFLG = False Then
            Dim getDataList1 = outMachine.MachineInf.MaterialInf.Where(Function(x) x.Category.Trim = BSITE_CATEGORY_FRAME).ToList
            Dim getDatas1 = getDataList1.Where(Function(x) x.Type = lbl0202.Text.Split(DEF_SLASH)(0).Trim).ToList
            If getDatas1.Count = 0 Then
                setBsiteFrame()
            End If
        End If
        '取得できないorエラー応答の場合はNG
        If outMachine.Header Is Nothing OrElse outMachine.Header.Status = STS_ERROR Then
            PutLog(Me.ToString, "getBsiteData", getMsgStr("MSG00135", lbl0200.Text))
            MsgBox(getMsgStr("MSG00135", lbl0200.Text))
            txt0303.BackColor = ERROR_INIT_COLOR
            lbl0303.BackColor = ERROR_INIT_COLOR
            txt0303.Text = String.Empty
            m_iScore(SCORE_NUM.PASTE1) = 0
            Return False
        End If
        'ペーストチェック処理
        If Not checkPaste(outMachine) Then
            PutLog(Me.ToString, "getBsiteData", "checkPaste False")
            Return False
        End If

        '框架check前，检验是否安装。如果没安装上，再次安装
        Dim getDataList = outMachine.MachineInf.MaterialInf.Where(Function(x) x.Category.Trim = BSITE_CATEGORY_FRAME).ToList
        Dim getDatas = getDataList.Where(Function(x) x.Type = lbl0202.Text.Split(DEF_SLASH)(0).Trim).ToList
        If getDatas.Count = 0 Then
            setBsiteFrame()
            outMachine = getViewLotService(clientProcCd)
        End If
        'フレームチェック処理
        If Not checkFrame(outMachine) Then
            PutLog(Me.ToString, "getBsiteData", "checkFrame False")

            Return False
        End If

        CheckCollScore()
        Return True
    End Function

    Private Sub setBsiteFrame()
        Dim mOutParam As New InSiteWebService.OutViewMachine
        Dim InHeader As New InSiteWebService.InHeader
        Dim clientStr As String = GetBsiteClientString()
        Dim InMaterialArr As InSiteWebService.Machine_Material()
        Dim dvFrameKatamei As DataRow()
        Dim frame As String
        If IcTag.szLotNo = "" Then Exit Sub

        If IsNothing(dtJyokenData) = False AndAlso dtJyokenData.Rows.Count > 0 Then

            dvFrameKatamei = dtJyokenData.Select("KOMOKUNAME='FRAME SUBSTRATE NAME'")
            frame = dvFrameKatamei(0)("KOMOKUDATA")
            If frame = lbl0303.Text Then Exit Sub
        Else
            Exit Sub
        End If

        mOutParam = ViewMachineService_GetInf(lblEquipID.Text, clientStr) '装置検索
        If (mOutParam.Header.Status = "SUCCESS") Then
            MaterialLotList.Clear()
            MachineNameList.Clear()
            Dim setEnd As Boolean = False
            ReDim InMaterialArr(mOutParam.MachineInf.MaterialInf.Length - 1)
            '材料情報を取得
            For i As Integer = 0 To mOutParam.MachineInf.MaterialInf.Length - 1
                InMaterialArr(i) = mOutParam.MachineInf.MaterialInf(i)
                If InMaterialArr(i).Category = "DBLF" Then
                    setEnd = True
                    InMaterialArr(i).Type = frame
                    InMaterialArr(i).TypeRev = "ZZZ"
                    InMaterialArr(i).OriginalLot = ""
                End If
            Next
            If setEnd = False Then
                Dim len As Integer = InMaterialArr.Length + 1
                ReDim Preserve InMaterialArr(len)
                InMaterialArr(len - 1) = New InSiteWebService.Machine_Material
                InMaterialArr(len - 1).Category = "DBLF"
                InMaterialArr(len - 1).Type = frame
                InMaterialArr(len - 1).TypeRev = "ZZZ"
                InMaterialArr(len - 1).OriginalLot = ""
            End If
            '治具情報を取得
            For Each OutSubMachine As InSiteWebService.Machine_SubMachine In mOutParam.MachineInf.SubMachineInf
                MachineNameList.Add(OutSubMachine.Name)
            Next
        End If

        '治具情報
        Dim MachineNameListArr(MachineNameList.Count) As String
        For i As Integer = 0 To MachineNameList.Count - 1
            MachineNameListArr(i) = MachineNameList(i)
        Next

        Dim InMaterial As New InSiteWebService.Machine_Material
        Dim inputBsite_MachineSetup As New InSiteWebService.InMachineSetup
        Dim outputBsite_MachineSetup As New InSiteWebService.OutMachineSetup

        inputBsite_MachineSetup.Employee = UserNo
        inputBsite_MachineSetup.Machine = lblEquipID.Text
        inputBsite_MachineSetup.MaterialInf = InMaterialArr ' mOutParam.MachineInf.MaterialInf
        inputBsite_MachineSetup.SubMachine = MachineNameListArr '元の治具を保留
        'End If
        '装置設定
        outputBsite_MachineSetup = MachineSetupService_Execute(inputBsite_MachineSetup)
        '戻り情報を保持
        outHeader = outputBsite_MachineSetup.Header
        If Not (outHeader.Status = "SUCCESS") Then
            setCheckInfo("给设备设定框架时出错。")
        End If
        SetBsiteFrameFLG = True
    End Sub

    ' 使用期限のチェックを行う
    'Private Function checkExpirationDate(labelDate As Label, index As Integer) As Boolean
    '    '現在の日付を取得する
    '    Dim dtNow As DateTime = m_cData.GetServerTime()
    '    Dim dt As DateTime

    '    '日付に変換できるかどうか
    '    If DateTime.TryParse(labelDate.Text, dt) Then
    '        dt.AddMinutes(-20) 'ADD MIAO　20191227 UPD 材料期限-20分をオーバーしたらエラーメッセージを表示する
    '        '変換出る場合、現在の日付と比較する
    '        If DateTime.Compare(dt, dtNow) < 0 OrElse DateTime.Compare(dt, dtNow) = 0 Then
    '            ' 使用期限 <= 現在時刻の場合，エラーを表示する
    '            labelDate.BackColor = Color.Red
    '            MsgBox(getMsgStr("MSG00049", lbl0100.Text))
    '            m_iScore(index) = PASS_SCORE_WAIT_CHECK
    '            Return False
    '        End If
    '    Else
    '        labelDate.BackColor = Color.Red
    '        MsgBox(getMsgStr("MSG00048", lbl0100.Text))
    '        m_iScore(index) = PASS_SCORE_WAIT_CHECK
    '        Return False
    '    End If
    '    Return True
    'End Function

    'ペースト B-Siteチェック
    Private Function checkPaste(outMachine As InSiteWebService.OutViewMachine) As Boolean
        initPasteParams(True)

        If String.IsNullOrEmpty(lbl0102.Text) Then
            ' 製造条件が空の場合はチェックを行わないで、着工チェックフラグを立てる
            m_iScore(SCORE_NUM.PASTE1) = PASS_SCORE_CHECKED
            m_iScore(SCORE_NUM.PASTE2) = PASS_SCORE_CHECKED
            Return True
        End If

        ' b-Site取得エラーチェック
        'UPD 苗 2018/1/9 材料ロットを取得(OriginalLot -> Lot)
        Dim getDataList = outMachine.MachineInf.MaterialInf.Where(Function(x) x.Category.Trim = BSITE_CATEGORY_PASTE And x.Type IsNot Nothing And x.Lot IsNot Nothing And x.DueDate IsNot Nothing).ToList

        If getDataList.Count = 0 Then
            PutLog(Me.ToString, "getBsiteData", "checkPaste MSG00101")
            MsgBox(getMsgStr("MSG00101", lbl0100.Text))
            txt0103.BackColor = ERROR_INIT_COLOR
            lbl0103.BackColor = ERROR_INIT_COLOR
            m_iScore(SCORE_NUM.PASTE1) = PASS_SCORE_WAIT_CHECK
            m_iScore(SCORE_NUM.PASTE2) = PASS_SCORE_WAIT_CHECK
            Return False
        End If

        '製造条件でリストを検索
        Dim getDatas = getDataList.Where(Function(x) x.Type = lbl0102.Text.Split(DEF_SLASH)(0).Trim).ToList
        If getDatas.Count = 0 Then
            PutLog(Me.ToString, "getBsiteData", "checkPaste MSG10030")

            MsgBox(getMsgStr("MSG10030", lbl0100.Text, makeViewMachineTypeString(getDataList)))
            txt0103.BackColor = ERROR_INIT_COLOR
            lbl0103.BackColor = ERROR_INIT_COLOR
            m_iScore(SCORE_NUM.PASTE1) = PASS_SCORE_WAIT_CHECK
            m_iScore(SCORE_NUM.PASTE2) = PASS_SCORE_WAIT_CHECK
            Return False
        End If

        For Each item In getDatas.Select(Function(Value, Index) New With {Value, Index})
            Dim Type As TextBox
            Dim oLot As TextBox
            Dim expiryDate As Label
            ' 画面の項目振り分け
            If item.Index = 0 Then
                Type = txt0103
                oLot = txt0104
                expiryDate = lbl0106
                'DEL 苗 2018/1/30 BEGIN 材料１だけの対応
                'ElseIf item.Index = 1 Then
                '    Type = txt0203
                '    oLot = txt0204
                '    expiryDate = lbl0206
                'DEL 苗 2018/1/30 END 材料１だけの対応
            Else
                Exit For
            End If

            Type.Text = item.Value.Type.Trim
            oLot.Text = item.Value.Lot.Trim 'UPD 苗 2018/1/9 材料ロットを取得(OriginalLot -> Lot)
            expiryDate.Text = item.Value.DueDate.Trim
            'If Not checkExpirationDate(expiryDate, item.Index) Then
            '    Return False
            'End If
        Next
        Me.Refresh()
        ' 着工チェックフラグを立てる
        m_iScore(SCORE_NUM.PASTE1) = PASS_SCORE_CHECKED
        m_iScore(SCORE_NUM.PASTE2) = PASS_SCORE_CHECKED
        Return True
    End Function

    'フレーム・基板型名 B-Siteチェック
    Private Function checkFrame(outMachine As InSiteWebService.OutViewMachine) As Boolean
        initFrameParams(True)

        If String.IsNullOrEmpty(lbl0202.Text) Then
            ' 製造条件が空の場合はチェックを行わないで、着工チェックフラグを立てる
            m_iScore(SCORE_NUM.FRAME1) = PASS_SCORE_CHECKED
            m_iScore(SCORE_NUM.FRAME2) = PASS_SCORE_CHECKED
            m_iScore(SCORE_NUM.FRAME3) = PASS_SCORE_CHECKED
            Return True
        End If

        ' b-Site取得エラーチェック
        Dim getDataList = outMachine.MachineInf.MaterialInf.Where(Function(x) x.Category.Trim = BSITE_CATEGORY_FRAME).ToList
        If getDataList.Count = 0 Then
            PutLog(Me.ToString, "getBsiteData", "checkFrame MSG00101")

            MsgBox(getMsgStr("MSG00101", lbl0200.Text))
            txt0303.BackColor = ERROR_INIT_COLOR
            lbl0303.BackColor = ERROR_INIT_COLOR
            m_iScore(SCORE_NUM.FRAME1) = PASS_SCORE_WAIT_CHECK
            m_iScore(SCORE_NUM.FRAME2) = PASS_SCORE_WAIT_CHECK
            m_iScore(SCORE_NUM.FRAME3) = PASS_SCORE_WAIT_CHECK
            Return False
        End If

        '製造条件でリストを検索
        Dim getDatas = getDataList.Where(Function(x) x.Type = lbl0202.Text.Split(DEF_SLASH)(0).Trim).ToList
        If getDatas.Count = 0 Then
            PutLog(Me.ToString, "getBsiteData", "checkFrame MSG10030")
            MsgBox(getMsgStr("MSG10030", lbl0200.Text, makeViewMachineTypeString(getDataList)))
            txt0303.BackColor = ERROR_INIT_COLOR
            lbl0303.BackColor = ERROR_INIT_COLOR
            m_iScore(SCORE_NUM.FRAME1) = PASS_SCORE_WAIT_CHECK
            m_iScore(SCORE_NUM.FRAME2) = PASS_SCORE_WAIT_CHECK
            m_iScore(SCORE_NUM.FRAME3) = PASS_SCORE_WAIT_CHECK
            Return False
        End If

        'データ反映
        For Each item In getDatas.Select(Function(Value, Index) New With {Value, Index})
            If item.Index = 0 Then
                txt0303.Text = item.Value.Type
                txt0304.Text = item.Value.OriginalLot 'ADD 苗 2018/1/30 フレームのメーカーロット
            End If
        Next

        ' 着工チェックフラグを立てる
        m_iScore(SCORE_NUM.FRAME1) = PASS_SCORE_CHECKED
        m_iScore(SCORE_NUM.FRAME2) = PASS_SCORE_CHECKED
        m_iScore(SCORE_NUM.FRAME3) = PASS_SCORE_CHECKED

        Return True
    End Function

    ''' <summary>
    ''' ペーストの表示初期化
    ''' </summary>
    ''' <param name="isStringClear">文字列をクリアするか</param>
    Private Sub initPasteParams(isStringClear As Boolean)
        If isStringClear Then
            '入力文字列のクリア
            txt0103.Text = String.Empty
            txt0104.Text = String.Empty
            lbl0106.Text = String.Empty
            'DEL 苗 2018/1/30 BEGIN 材料１だけの対応
            'txt0203.Text = String.Empty
            'txt0204.Text = String.Empty
            'lbl0206.Text = String.Empty
            'DEL 苗 2018/1/30 END 材料１だけの対応
        End If
        'ペースト1
        txt0103.BackColor = NORMAL_INIT_COLOR
        lbl0103.BackColor = NORMAL_INIT_COLOR
        txt0104.BackColor = NORMAL_INIT_COLOR
        lbl0104.BackColor = NORMAL_INIT_COLOR
        lbl0106.BackColor = NORMAL_INIT_COLOR

        'DEL 苗 2018/1/30 BEGIN 材料１だけの対応
        ''ペースト2
        'txt0203.BackColor = NORMAL_INIT_COLOR
        'lbl0203.BackColor = NORMAL_INIT_COLOR
        'txt0204.BackColor = NORMAL_INIT_COLOR
        'lbl0204.BackColor = NORMAL_INIT_COLOR
        'lbl0206.BackColor = NORMAL_INIT_COLOR
        'DEL 苗 2018/1/30 END 材料１だけの対応
    End Sub

    ''' <summary>
    ''' フレームの表示初期化
    ''' </summary>
    ''' <param name="isStringClear">文字列をクリアするか</param>
    Private Sub initFrameParams(isStringClear As Boolean)
        If isStringClear Then
            '入力文字列のクリア
            txt0303.Text = String.Empty
            txt0304.Text = String.Empty
        End If
        ' 背景色初期化
        txt0303.BackColor = NORMAL_INIT_COLOR
        lbl0303.BackColor = NORMAL_INIT_COLOR
        txt0304.BackColor = NORMAL_INIT_COLOR
        lbl0304.BackColor = NORMAL_INIT_COLOR
    End Sub

    '再読込ボタン押下
    Protected Sub btnRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        getBsiteData()
    End Sub

    '補充ボタン押下
    Protected Sub btnFrameAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        '外部EXEを呼び出す
        Dim strRetStatus As String = Execute_Command(IIf(AProcCD() = "", lblProcessCD.Text, AProcCD), EXEC_PG_TAG_FRAME, txtLotNo.Text, g_EQUIP_NO, "", UserNo)
        '戻り値による処理は未定のため、現在は未実装
        If strRetStatus = "0" Then
            ' bSite連携
            getBsiteData()

        Else
            MsgBox(getMsgStr("MSG10009", strRetStatus))
        End If
    End Sub

    'ペースト補充ボタン押下
    Protected Sub btnPasteAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        '外部EXEを呼び出す
        Dim strRetStatus As String = Execute_Command(IIf(AProcCD() = "", lblProcessCD.Text, AProcCD), EXEC_PG_TAG_PASTE, txtLotNo.Text, g_EQUIP_NO, "", UserNo)
        '戻り値による処理は未定のため、現在は未実装
        If strRetStatus = "0" Then
            ' bSite連携
            getBsiteData()
            'Dim rd As New receiveCommandData
            'rd.matType = EXEC_PG_TAG_PASTE
            'setChangeForPQC(rd)
        Else
            MsgBox(getMsgStr("MSG10009", strRetStatus))
        End If
    End Sub
    Overrides Function chkMatChanged() As Boolean
        Dim pqc As New clsPQCCheck
        Dim katamei As String = ""
        Dim matlot As String = ""
        Dim rtn As Boolean = False
        pqc.selectPQC(lblEquipID.Text, katamei, matlot)

        If katamei = "" And txt0103.Text <> "" And txt0104.Text <> "" Then
            pqc.insertPQC(lblEquipID.Text, txt0103.Text, txt0104.Text)
            rtn = False
        End If
        If katamei <> "" Then
            If katamei = txt0103.Text And matlot = txt0104.Text Then
                rtn = False
            Else
                If txt0103.Text <> "" And txt0104.Text <> "" Then
                    pqc.updatePQC(lblEquipID.Text, txt0103.Text, txt0104.Text)
                    setChangeForPQC(EXEC_PG_TAG_PASTE)
                End If

                rtn = True
            End If
        End If
        Return rtn
    End Function

    ' 表示部のStringをIntegerに変換する
    Private Function convertInteger(inStr As String) As Integer
        Dim ret As Integer = 0
        If Not String.IsNullOrEmpty(inStr) Then
            ret = CInt(inStr)
        End If
        Return ret
    End Function

    '過不足計算用（必要ある画面のみ）
    Protected Overrides Sub ExcessDeficiencyReCalc()
        'ADD 苗 2018/1/27 BEGIN
        If m_ProcessStatus = ProcessStatus.Ready Or m_ProcessStatus = ProcessStatus.TagSet Then
            lblExcess.Text = 0
        Else
            Dim iFail As Integer = convertInteger(lblFailedCnt.Text)        '不良数
            Dim iComp As Integer = convertInteger(lblCompleteCnt.Text)      '良品数
            Dim iInput As Integer = convertInteger(lblInputCnt.Text)        '前工程良品数
            '過不足 = 良品数+不良数 - 前工程良品数
            Dim excess As Integer = iComp + iFail - iInput
            lblExcess.Text = excess

            Debug.WriteLine(String.Format("{0} : 過不足計算値 = {1}", System.Reflection.MethodBase.GetCurrentMethod.Name, excess))
        End If
        'ADD 苗 2018/1/27 END
    End Sub
    'ADD 苗 2018/1/5 BEGING
    Overrides Sub GetDefectCata()
        MyBase.GetDefectCata()
        setXInnNum() 'ADD 苗 2018/1/5
    End Sub

    Private Sub lblThrowChips_TextChanged(sender As Object, e As EventArgs) Handles lblThrowChips.TextChanged
        setXInnNum() 'ADD 苗 2018/1/5
    End Sub

    Private Sub lblEmptyChips_TextChanged(sender As Object, e As EventArgs) Handles lblEmptyChips.TextChanged
        setXInnNum() 'ADD 苗 2018/1/5
    End Sub

    Protected Overrides Sub setXInnNum()
        If IsNothing(IcTag.szLotNo) Then Exit Sub
        IcTag.iFrameIDUse = CInt(m_cEquipMat.getframeIDUse(IcTag.szLotNo))

        '×印数＝不良数 - 廃棄チップ数 + 空チップ数
        If lblEmptyChips.Text <> "" AndAlso lblFailedCnt.Text <> "" AndAlso lblThrowChips.Text <> "" Then
            lblCrossCnt.Text = CInt(lblFailedCnt.Text) - CInt(lblThrowChips.Text) + CInt(lblEmptyChips.Text)
        End If
        setCompleteCnt() 'ADD 苗 2018/1/11 END

    End Sub
    'ADD 苗 2018/1/5 END
    Protected Overrides Sub setCompleteCnt()
        If IsNothing(IcTag.szLotNo) Then Exit Sub
        IcTag.iFrameIDUse = CInt(m_cEquipMat.getframeIDUse(IcTag.szLotNo))

        If m_szFrameid_comp = 1 And IcTag.iFrameIDUse = 1 Then
        Else
            '完成数＝フレーム数×PD個数－空チップ数－(不良数－廃棄チップ数)
            Dim intPcbCnt As Integer = 0 'フレーム数
            Dim intPDCnt As Integer = 0 'PD個数
            Dim intEmptyChips As Integer = 0 '空チップ数
            Dim intFailedCnt As Integer = 0 '不良数
            Dim intThrowChips As Integer = 0 '廃棄チップ数

            If lblPcbCnt.Text <> "" Then intPcbCnt = CInt(lblPcbCnt.Text)
            intPDCnt = CInt(strDP_CNT)
            If lblEmptyChips.Text <> "" Then intEmptyChips = CInt(lblEmptyChips.Text)
            If lblFailedCnt.Text <> "" Then intFailedCnt = CInt(lblFailedCnt.Text)
            If lblThrowChips.Text <> "" Then intThrowChips = CInt(lblThrowChips.Text)

            lblCompleteCnt.Text = intPcbCnt * intPDCnt - intEmptyChips - (intFailedCnt - intThrowChips)
        End If
    End Sub
    'Protected Overloads Sub lblPcbCnt_TextChanged(sender As Object, e As EventArgs)  'UPD 苗 2018/1/17
    '    setXInnNum() 'ADD 苗 2018/1/5
    'End Sub

    '計上完成正常時の画面初期化
    Protected Overrides Sub initializForm()
        MyBase.initializForm()
        inputDataClear()
    End Sub

    'ウェハケースNoタブキー対応
    Private Sub txtData_PreviewKeyDown(ByVal sender As Object, ByVal e As PreviewKeyDownEventArgs) Handles txt0903.PreviewKeyDown
        'タブキーが押下された場合は、改行コードと見なし処理を行う
        If e.KeyCode = Keys.Tab Then
            e.IsInputKey = True
            WaferTxtData_KeyPress(sender, New KeyPressEventArgs(vbCr))
        End If
    End Sub


    'ラックケースNoタブキー対応
    Private Sub txtRackNoDB_PreviewKeyDown(ByVal sender As Object, ByVal e As PreviewKeyDownEventArgs) _
        Handles txt1002.PreviewKeyDown, txt1003.PreviewKeyDown, txt1004.PreviewKeyDown, txt1005.PreviewKeyDown, txt1006.PreviewKeyDown
        'タブキーが押下された場合は、改行コードと見なし処理を行う
        If e.KeyCode = Keys.Tab Then
            e.IsInputKey = True
            txtRackNoDB_KeyPress(sender, New KeyPressEventArgs(vbCr))
        End If
    End Sub

    '>>2018/1/31 佐川 キャリア交換対応
    'IcTag保存内容設定
    Protected Overrides Sub icTagDataSet()
        '製造完成、計上完成時は画面入力値の値を設定する。
        If execMode.Equals(COMPLETE) Or execMode.Equals(TOTAL) Then
            IcTag.container1 = txt1002.Text
            IcTag.container2 = txt1003.Text
            IcTag.container3 = txt1004.Text
            IcTag.container4 = txt1005.Text
            IcTag.container5 = txt1006.Text
            '>>2018/2/19 大賀 No75 空チップ数量のl_tag_lotdata化
            IcTag.emptyChipNum = IIf(String.IsNullOrEmpty(lblEmptyChips.Text), 0, CInt(lblEmptyChips.Text))
            '<<2018/2/19 大賀 No75 空チップ数量のl_tag_lotdata化
        Else
            '初期値をそのまま保存するため、変更しない。
        End If
    End Sub
    '<<2018/1/31 佐川 キャリア交換対応

    '>> 2018/2/22 佐川 ラックNo入力動作を統一
    'バーコード入力完了
    Protected Sub WaferTxtData_KeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs)
        '頭に付いている'%'を消す
        Static Dim fIsPercentInput As Boolean = False
        If e.KeyChar = CChar("%") OrElse e.KeyChar = CChar("％") Then
            fIsPercentInput = True
            e.Handled = True
            Exit Sub
        End If
        If fIsPercentInput Then
            fIsPercentInput = False
            e.Handled = True
            Exit Sub
        End If

        If e.KeyChar = vbCr Then

            Dim txtData As TextBox = CType(sender, TextBox) 'Add 苗 2018/4/10
            txtData.Text = txtData.Text.ToUpper 'Add 苗 2018/4/10
            'WaferTxtData_LostFocus(sender, e)
            If txtDiffLot.Text <> "" Or lblDiffLotNo.Text <> "" Then

                'ウェハケースNoの空白チェック
                Dim title As String = lbl0900.Text.Replace(Environment.NewLine, "")
                If Not checkBlank(txt0903.Text, title) Then
                    txt0903.BackColor = ERROR_INIT_COLOR
                    lbl0903.BackColor = ERROR_INIT_COLOR
                    txt0903.Focus()
                    txt0903.SelectAll()
                    m_iScore(SCORE_NUM.WAFERCASE) = PASS_SCORE_WAIT_CHECK
                    '前工程一致チェック
                ElseIf preWaferCaseNo <> txt0903.Text Then
                    MsgBox(getMsgStr("MSG00093", lbl0900.Text, txt0903.Text))
                    txt0903.BackColor = ERROR_INIT_COLOR
                    lbl0903.BackColor = ERROR_INIT_COLOR
                    txt0903.Focus()
                    txt0903.SelectAll()
                    m_iScore(SCORE_NUM.WAFERCASE) = PASS_SCORE_WAIT_CHECK
                    '>>20180313 大賀 搬送容器桁数チェックを共通化
                    ' ウェハケースNoの桁数チェック
                ElseIf Not isCheckCaseLength(txt0903, WAFER_CASE_NO_LENGTH, lbl0903) Then
                    m_iScore(SCORE_NUM.WAFERCASE) = PASS_SCORE_WAIT_CHECK
                    '<<20180313 大賀 搬送容器桁数チェックを共通化
                Else
                    txt0903.Enabled = False
                    txt0903.BackColor = ENTERED_INIT_COLOR
                    lbl0903.BackColor = ENTERED_INIT_COLOR
                    m_iScore(SCORE_NUM.WAFERCASE) = PASS_SCORE_CHECKED
                    CheckCollScore()
                End If

                'AddHandler txt0903.LostFocus, AddressOf WaferTxtData_LostFocus
                '<< 2018/2/22 佐川 ラックNo入力動作を統一
            End If
            If AutoManualMode = 0 And AUTO_MANUAL_BTN = TYPE_AUTO Then


                'Add 苗 2019/11/24 Begin
                Dim tmpLotNo As DataTable
                If txt0903.Text = "" Then Exit Sub
                SetBsiteFrameFLG = False

                tmpLotNo = getLotNoListByRack(txt0903.Text, m_szProc)

                If tmpLotNo.Rows.Count = 0 Then

                    MsgBox(getMsgStr("MSG10059", txt0903.Text))
                    Exit Sub
                End If

                If (txtLotNo.Text = "" And tmpLotNo.Rows(0)(0) <> "") Or
                    (tmpLotNo.Rows(0)(0) <> "" And txtLotNo.Text <> tmpLotNo.Rows(0)(0)) Then
                    txtLotNo.Text = tmpLotNo.Rows(0)(0)
                    If txtLotNo.Text.Trim() <> "" Then
                        txtLotNo_KeyPress(txtLotNo, New KeyPressEventArgs(vbCr))
                        If AutoManualMode = 0 Then
                            txt0903.Text = IcTag.container1
                        End If

                    End If
                End If
                'Add 苗 2019/11/24 End
            End If
        End If
    End Sub

    ' ラックNo用バーコードクリック
    Protected Sub btnBeforeRackNo_Click(ByVal sender As Object, ByVal e As EventArgs)

        ' 入力フォーカスの設定
        Dim btn As Button = CType(sender, Button)
        Dim txtData As TextBox = btn.Parent.Controls.Find(String.Format("txt{0}03", btn.Tag.ToString), False)(0)
        Dim lblData As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}03", txtData.Tag.ToString), False)(0)

        txtData.Text = String.Empty
        txtData.Enabled = True
        txtData.Focus()

        txtData.SelectAll()
        txtData.BackColor = FOCUS_INIT_COLOR
        lblData.BackColor = FOCUS_INIT_COLOR
    End Sub
    '<< 2018/2/22 佐川 ラックNo入力動作を統一

    ' >> 20180307 大賀 作業者入力確定時に次の入力にフォーカスを移動する
    ''' <summary>
    ''' 作業者入力後のフォーカスを各画面で設定する
    ''' 各画面でオーバーライドされない場合はTabIndex順に移動する
    ''' </summary>
    ''' <param name="inputType">作業者入力タイプ</param>
    ''' <param name="nowControl">対象コントロール</param>
    Protected Overrides Sub setNextFocus(ByVal inputType As OPERATER_INPUT_TYPE, ByVal nowControl As Control)
        If m_ProcessStatus <> ProcessStatus.Ready Then  ' ロット未入力の場合は処理しない
            If IcTag.Status = TagProcessStatus.Ready Then   ' 未着工
                If inputType = OPERATER_INPUT_TYPE.START_OPE Then
                    tabBase.SelectedTab = TabPageSp ' タブの移動
                    If String.IsNullOrEmpty(txt0903.Text) Then  ' 未入力の場合に入力可能にする
                        btnBarCodeWafer.PerformClick()  ' バーコード入力ボタンを押す
                        Exit Sub
                    End If
                End If
            ElseIf IcTag.Status = TagProcessStatus.Processing Then  ' 着工中
                If inputType = OPERATER_INPUT_TYPE.END_OPE Then
                    tabBase.SelectedTab = TabPageSp ' タブの移動
                    If String.IsNullOrEmpty(txt1002.Text) Then  ' 未入力の場合に入力可能にする
                        btnBarCodeRack.PerformClick()  ' バーコード入力ボタンを押す
                        Exit Sub
                    End If
                End If
            ElseIf IcTag.Status = TagProcessStatus.ManufComplete Then ' 製造完成

            End If
        End If
        ' 各画面個別のフォーカスに移動しない場合は次のTabIndexに移動
        SelectNextControl(nowControl, True, True, True, True)
    End Sub
    ' << 20180307 大賀 作業者入力確定時に次の入力にフォーカスを移動する

    ' >> 20180710 佐川 ラックNo途入力改善
    Public Overrides Sub rackInputFocus(ByVal sender As Object, ByVal e As System.EventArgs)
        '着工中のみ選択可能にする
        If IcTag.Status = TagProcessStatus.Processing Then
            MyBase.rackInputFocus(sender, e)
        End If
    End Sub
    ' << 20180710 佐川 ラックNo途入力改善

    '--自動着完工用実装分--BEGIN　2019/11/29
    Protected Overrides Sub setBeforeRackNo(Optional inputRackNo As String = "")
        If IsNothing(IcTag.szLotNo) = False Then
            If IcTag.container1 <> "" Then
                txt0903.Text = IcTag.container1
                m_iScore(SCORE_NUM.WAFERCASE) = PASS_SCORE_CHECKED
            End If
        End If
    End Sub

    Protected Overrides Function setAfterRackNo(receiveData As receiveCommandData) As Boolean
        If receiveData.UrackNoList.Count = 0 Then
            Return False
        End If
        '完工MS料盒设置
        If IsNothing(receiveData.UrackNoList(0)) = False Then
            txt1002.Text = receiveData.UrackNoList(0)
        End If
        If IsNothing(receiveData.UrackNoList(1)) = False Then
            txt1003.Text = receiveData.UrackNoList(1)
        End If
        If IsNothing(receiveData.UrackNoList(2)) = False Then
            txt1004.Text = receiveData.UrackNoList(2)
        End If
        If IsNothing(receiveData.UrackNoList(3)) = False Then
            txt1005.Text = receiveData.UrackNoList(3)
        End If
        If IsNothing(receiveData.UrackNoList(4)) = False Then
            txt1006.Text = receiveData.UrackNoList(4)
        End If
        Return True
    End Function
    ''' <summary>
    ''' 设置画面控件是否可用
    ''' </summary>
    ''' <param name="mode">True:自动状态，False：手动状态</param>
    Protected Overrides Sub setAutoScreen(mode As Boolean)

        Dim setColor As Color = NORMAL_INIT_COLOR
        Dim setEnabled As Boolean = Not (mode)

        '完工后，是否清空画面，清空后ictag也被清空（手动时为true,自动时为false)
        initializForm_FLG = setEnabled

        If mode = True Then
            setColor = NORMAL_INIT_COLOR
        Else
            setColor = BUTTON_INIT_COLOR
        End If
        '受入MSラック
        txt0903.Enabled = setEnabled

        '完工MSラック
        txt1002.Enabled = setEnabled
        txt1003.Enabled = setEnabled
        txt1004.Enabled = setEnabled
        txt1005.Enabled = setEnabled
        txt1006.Enabled = setEnabled

        '背景色設定
        '受入MSラック
        txt0903.BackColor = setColor
        lbl0903.BackColor = setColor

        '完工MSラック
        txt1002.BackColor = setColor
        txt1003.BackColor = setColor
        txt1004.BackColor = setColor
        txt1005.BackColor = setColor
        txt1006.BackColor = setColor

        lbl1002.BackColor = setColor
        lbl1003.BackColor = setColor
        lbl1004.BackColor = setColor
        lbl1005.BackColor = setColor
        lbl1006.BackColor = setColor

        btnBarCodeWafer.Enabled = setEnabled
        'btnErrInput.Enabled = False

    End Sub

    Overrides Sub SetProcNo(ByRef procNo As String)
        m_szProc = PROC_CD_DBS
        procNo = PROC_CD_DBS
    End Sub
    Public Overrides Function AProcStartCompleteFLG() As Boolean
        Return True
    End Function

    Public Overrides Function AProcCD() As String
        Return PROC_CD_DBA
    End Function
    Overrides Function doChkFrameID() As Boolean
        Return True
    End Function
    ''' <summary>
    ''' コマンド受信
    ''' 受信コマンドの解析結果を各画面に渡す
    ''' </summary>
    ''' <param name="receiveData">受信コマンド</param>
    Protected Overrides Sub CommandReceive(receiveData As receiveCommandData)
        'MsgBox("Childクラスの「CommandReceive」メソッドに入った！")
        HideCommandWaiting()
        If IsNothing(receiveData) Then
            Exit Sub
        End If
        '--------着工コマンド処理-------    
        If AUTO_MANUAL_BTN = TYPE_AUTO AndAlso receiveData.commandId = COMMAND_LN Then
            If chkErrorRackNo(receiveData, receiveData.commandId) = False Then
                Exit Sub
            End If
            PutLog(Me.ToString, "DBLN", "Begin") '2020/8/8 ver.58
            'MsgBox("LN　コマンドを受け入れた！")
            If NP_IU_RTN = False Then 'ADD 2020/8/17 miaojf Ver.70
                WaitLnCommand = receiveData
                Exit Sub
            End If
            If Me.panelHeader.BackColor <> Color.FromKnownColor(KnownColor.Gold) Then
                btnAuto.PerformClick()
            End If

            LN_FLAG = True
            'RACKからLOT情報を取得し、画面に設定する
            If IsNothing(IcTag.szLotNo) OrElse IcTag.Status = TagProcessStatus.Ready Then
                '入力ラックNoからロットNoを取得
                If receiveData.LrackNoList.Count = 0 Then
                    MsgBox("扫码error！")
                    Exit Sub
                End If
                dtLot = getLotNoListByRack(receiveData.LrackNoList(0), m_szProc)
                If dtLot.Rows.Count = 0 Then

                    MsgBox(getMsgStr("MSG10059", receiveData.LrackNoList(0)))
                    Exit Sub
                End If
                txtLotNo.Text = dtLot.Rows(0)(0)
                Command_LD_Received = False
                txtLotNo_KeyPress(txtLotNo, New KeyPressEventArgs(vbCr))
                setBeforeRackNo(receiveData.LrackNoList(0))

                'txtOptNoStt.Text = "INSITEADMIN" 'TODO：DEL
                'If getBsiteData() = False Then Exit Sub
            End If

            'LCコマンドの送信
            'sendLCCommand(COMMAND_LC, g_CURRENT_EQUIP_ID, lblkindNm.Text, txtOptNoStt.Text, txtLotNo.Text, lblInputCnt.Text, "", lblInputFrm.Text, lblShape.Text, lblInputCross.Text, IcTag.szDifLotNo, lblPbLayout.Text)
            '    If m_fIsGettingData=True Then
            '    'コマンドの待ち画面
            '    ShowCommandWaiting()
            'End If
            PutLog(Me.ToString, "DBLN", "END") '2020/8/8 ver.58
        End If
        If receiveData.commandId = COMMAND_LD Then
            'MsgBox("LD　コマンドを受け入れた！")

            'ADD MIAOJF 2020/07/18 begin
            If reconfirmNBIGS = True Then
                If receiveData.result = COMMAND_RESULT_OK Then
                    setCheckInfo(getMsgStr("MSG00117", "照合成功。"))
                    PutLog(Me.ToString, "RECEIVEDATA LD OK2", getMsgStr("MSG00117", "照合成功。")) '2020/8/8 ver.57

                Else
                    ShowCommandResult(receiveData.result)
                    PutLog(Me.ToString, "RECEIVEDATA LD NG2", "照合失败。") '2020/8/8 ver.57

                End If
                reconfirmNBIGS = False
                Exit Sub
            End If
            'ADD MIAOJF 2020/07/18 END

            If receiveData.result = COMMAND_RESULT_OK Then

                'ADD MIAO 2019/12/21 特殊银浆的时候，变为手动处理模式--------
                'If lbl0102.Text <> "" Then
                '    Dim specPaste As String = g_DBSFCommon.GetFactoryInfo_Str2("99018", "")
                '    If specPaste = "" Then Exit Sub

                '    If specPaste.Contains(lbl0102.Text) Then
                '        btnManual.PerformClick()
                '        Exit Sub
                '    End If
                'End If
                'ADD MIAO 2019/12/21 END 特殊银浆的时候----------------------

                If LN_FLAG = False Then
                    If txt0903.Text = "" Then Exit Sub
                    dtLot = getLotNoListByRack(txt0903.Text, m_szProc)
                End If

                If IsNothing(dtLot) OrElse dtLot.Rows.Count = 0 Then

                    MsgBox(getMsgStr("MSG10059", txt0903.Text))
                    Exit Sub
                End If
                For i As Integer = 0 To dtLot.Rows.Count - 1
                    If txtLotNo.Text <> dtLot.Rows(i)(0) Then
                        AutoManualMode = 1
                        txtLotNo.Text = dtLot.Rows(i)(0)
                        txtLotNo_KeyPress(txtLotNo, New KeyPressEventArgs(vbCr))
                        'txtOptNoStt.Text = "INSITEADMIN" 'TODO：DEL
                        setBeforeRackNo(IcTag.container1)
                        AutoManualMode = 0
                    End If
                    Command_LD_Received = True
                    If IcTag.Status = TagProcessStatus.Ready Then
                        WorkStart()
                    End If
                    Command_LD_Received = False
                Next

                '第１ロットを戻る
                If STS_SUCCESS.Equals(outHeader.Status) And txtLotNo.Text <> dtLot.Rows(0)(0) Then
                    txtLotNo.Text = dtLot.Rows(0)(0)
                    txtLotNo_KeyPress(txtLotNo, New KeyPressEventArgs(vbCr))
                End If
                'ADD MIAOJF 20200914 BEGIN
                If txtLotNo.Text = dtLot.Rows(0)(0) Then
                    If chkRandCheck(txtLotNo.Text.ToUpper) Then
                        setRandCheckInfo("LOT：" & txtLotNo.Text.ToUpper)
                    End If
                End If
                'ADD MIAOJF 20200914 END

            Else
                ShowCommandResult(receiveData.result)
            End If
        End If

        '--------完工コマンド処理-------
        If AUTO_MANUAL_BTN = TYPE_AUTO AndAlso receiveData.commandId = COMMAND_LH Then
            If chkErrorRackNo(receiveData, receiveData.commandId) = False Then
                Exit Sub
            End If
            PutLog(Me.ToString, "DBLH", "Begin") '2020/8/8 ver.58
            'MsgBox("LH　コマンドを受け入れた！")
            If isSameLot(receiveData) = False Then
                dtLot = getLotNoListByRack(receiveData.LrackNoList(0), m_szProc)

                If dtLot.Rows.Count = 0 Then

                    MsgBox(getMsgStr("MSG10059", receiveData.LrackNoList(0)))
                    Exit Sub
                End If
                txtLotNo.Text = dtLot.Rows(0)(0)
                LC_SEND_FLG = False
                txtLotNo_KeyPress(txtLotNo, New KeyPressEventArgs(vbCr))
                LC_SEND_FLG = True
                setBeforeRackNo(receiveData.LrackNoList(0))
            End If
            Me.Refresh()
            If IsNothing(dtLot) OrElse dtLot.Rows.Count = 0 Then
                '入力ラックNoからロットNoを取得
                dtLot = getLotNoListByRack(receiveData.LrackNoList(0), m_szProc)

                If dtLot.Rows.Count = 0 Then

                    MsgBox(getMsgStr("MSG10059", receiveData.LrackNoList(0)))
                    Exit Sub
                End If

                txtLotNo.Text = dtLot.Rows(0)(0)
                txtLotNo_KeyPress(txtLotNo, New KeyPressEventArgs(vbCr))
                setBeforeRackNo(receiveData.LrackNoList(0))
            End If

            If IcTag.Status <> TagProcessStatus.Processing Then
                Exit Sub
            End If

            LH_FLAG = True
            '不良内容をSF画面に表示する
            'setErrorInfo(receiveData)
            '完了MSラックNo.の設定
            If setAfterRackNo(receiveData) = False Then
                MsgBox("指令中的【完了料盒号】读取错误。请检查设备。")
                Exit Sub
            End If
            'txtOptNoEnd.Text = txtOptNoStt.Text 'TODO:DEL

            '最後のロットの場合、手動モードにする
            'If dtLot.Rows.Count = 1 Then
            '    initializForm_FLG = True
            '    btnManual.PerformClick()

            'Else
            Dim tmprackno As String = ""
            Dim tmpLotno As String = ""

            tmpLotno = txtLotNo.Text
            tmprackno &= "   " & txt1002.Text & vbCrLf
            tmprackno &= "   " & txt1003.Text & vbCrLf
            tmprackno &= "   " & txt1004.Text & vbCrLf
            tmprackno &= "   " & txt1005.Text & vbCrLf
            tmprackno &= "   " & txt1006.Text & vbCrLf

            'bSiteへ計上処理
            btnTotalComp.PerformClick()
            'totalCompAfter()

            Me.pnlCheckInfo.Visible = True
            Me.pnlCheckInfo.BringToFront()
            'txtChkInfo.Text = ""
            txtChkInfo.Text &= btnLotTxt.Text & " : " & vbCrLf
            txtChkInfo.Text &= "   " & tmpLotno & vbCrLf
            txtChkInfo.Text &= "料盒号：" & vbCrLf
            txtChkInfo.Text &= tmprackno

            'delFinishedLotFromLotList() 'UPD 2020/8/11 Miaojf Ver.58
            'End If


            'LFコマンドを送信
            'sendLFCommand(, g_CURRENT_EQUIP_ID, IcTag.szLotNo, lblkindNm.Text)

            '    'コマンドの待ち画面
            '    ShowCommandWaiting()

            'End If
            'If receiveData.commandId = COMMAND_LG Then
            'MsgBox("LG　コマンドを受け入れた！")
            'Dim rtnIU As String
            'Dim rtnNP As String
            'Dim strMPCCommand As String

            'If STS_SUCCESS.Equals(outHeader.Status) Then
            '    rtnIU = COMMAND_OK
            '    rtnNP = OK
            'Else
            '    rtnIU = COMMAND_NG
            '    rtnNP = NG
            'End If
            ''IUコマンドを送信
            'If LH_FLAG = True Then
            '    sendResponseCommand(COMMAND_IU, rtnIU)
            'End If

            ''TODO:追加要
            ''NPコマンドを送信
            'With IcTag
            '    strMPCCommand = createStORCompCommandStr(COMMAND_NP, rtnNP, .szLotNo, .szDifLotNo, lblProcessCD.Text, g_CURRENT_EQUIP_ID,
            '                       lblEquipID.Text, "", "", txtOptNoEnd.Text, lblkindNm.Text, lblShape.Text, lblPbLayout.Text, "")
            'End With
            'm_cEquipCommandControl.CommandSend(strMPCCommand)

            'LN_FLAG = False
            'LH_FLAG = False

            '画面表示を初期化
            'initializForm()
            PutLog(Me.ToString, "DBLH", "END") '2020/8/8 ver.58
        End If
        '--------材料補充処理-------
        If receiveData.commandId = COMMAND_DL Then

            '処理モード１か判断：１ではない場合、処理中止 1の場合、処理続行
            If receiveData.mode <> "1" Then Exit Sub
            If chkMaterialType(receiveData.matType) = True Then
                callAtlasExec(receiveData.matType, receiveData.matName)

                'bSiteのエラーメッセージ
                ''Dim bsiteMess As New clsDbBsiteMess
                ''Dim errDt = bsiteMess.GetErrorList(m_szIP)

                ''検索結果がある場合、NG。でなければ、OK
                Dim rtn As String = OK
                If bsiteRtn = True Then
                    rtn = OK
                Else
                    rtn = NG
                End If

                'If bsiteRtn = True Then setChangeForPQC(receiveData)
                ''DMコマンドの送信
                sendDMCommand(COMMAND_DM, rtn, lblEquipID.Text, receiveData.matType, receiveData.matName, receiveData.matLotNo, receiveData.caseNo)
                Try
                    'PQC CHECK
                    If chkMatChanged() Then
                        chkPQC()
                    End If
                Catch ex As Exception
                    MsgBox("PQC接口连接失败。")
                End Try
                getBsiteData()
                Me.Refresh()
            End If

        End If

    End Sub
    Overrides Sub delFinishedLotFromLotList()
        If IsNothing(dtLot) = False Then 'add miaojf 2020/8/12 Ver.61
            dtLot.Rows(0).Delete()
            dtLot.AcceptChanges()
        End If

    End Sub
    Protected Overrides Function isLastOneLot() As Boolean
        Dim rtnLotNo As String
        Dim rtn As Boolean
        rtnLotNo = getLastLotNoByGroupID(lblDiffLotNo.Text, m_szProc)
        If rtnLotNo = "" Then
            Return False
        End If
        '最後のロットの場合、trueをリターン
        If rtnLotNo = IcTag.szLotNo Then
            rtn = True
        Else
            rtn = False
        End If
        Return rtn
    End Function

    ''' <summary>
    ''' 材料区分が本工程の区分かどうか判断
    ''' </summary>
    ''' <param name="materialType">材料区分</param>
    ''' <returns>判断結果</returns>
    Protected Overrides Function chkMaterialType(materialType As String) As Boolean
        Dim rtn As Boolean = False

        'If EXEC_PG_TAG_FRAME.Contains(materialType.ToUpper) Or EXEC_PG_TAG_PASTE.Contains(materialType.ToUpper) Then
        '    rtn = True
        'End If
        If Trim(materialType) = "3" Or Trim(materialType) = "4" Then
            rtn = True
        End If
        Return rtn
    End Function

    ''' <summary>
    ''' atlasの材料補充を呼び出す
    ''' </summary>
    ''' <param name="materialType">材料区分</param>
    ''' <param name="mat">材料名</param>
    Protected Overrides Sub callAtlasExec(materialType As String, mat As String)

        Dim strMaterialType As String = ""
        If Trim(materialType) = "3" Then
            strMaterialType = EXEC_PG_TAG_FRAME
        ElseIf Trim(materialType) = "4" Then
            strMaterialType = EXEC_PG_TAG_PASTE
        End If
        If strMaterialType = "" Then Exit Sub

        '外部EXEを呼び出す
        Dim strRetStatus As String = Execute_Command(IIf(AProcCD() = "", lblProcessCD.Text, AProcCD), strMaterialType, txtLotNo.Text, g_EQUIP_NO, mat, UserNo)
        '戻り値による処理は未定のため、現在は未実装
        If strRetStatus = "0" Then
            ' bSite連携
            bsiteRtn = getBsiteData()
        Else
            MsgBox(getMsgStr("MSG10009", strRetStatus))
        End If
    End Sub
    '--自動着完工用実装分--END　2019/11/29

    Protected Overrides Sub doRandCheck(dtmst As DataTable, dtRecords As DataTable)
        Dim objRecords As New clsRandCheckRecords
        Dim objRCHistory As New clsRandCheckHistory
        Dim frameCount As Integer = 0
        '抜取検査履歴追加
        ''MSTの抜取検査数がある場合：履歴追加（車品）
        If dtmst.Rows(0)("CheckNum") <> 0 Then
            If strDP_CNT.Equals("0") = False Then
                frameCount = Math.Ceiling(dtmst.Rows(0)("CheckNum") / CInt(strDP_CNT))
            End If
            objRCHistory.insertData(IcTag.szLotNo, IcTag.szProcsCD, IcTag.container1, lblEquipID.Text, txtOptNoStt.Text, IcTag.iInput, dtmst.Rows(0)("CheckNum"), frameCount, dtmst.Rows(0)("NGNum"), 0, "", RC_TYPE)
            'setRandCheckInfo("LOT：" & IcTag.szLotNo)

        End If

        ''MSTの抜取検査数がない場合：AQLテーブルでAQLの抜取検査数を検索し、履歴追加（民用品）
        If IsDBNull(dtmst.Rows(0)("CheckNum")) OrElse dtmst.Rows(0)("CheckNum") = 0 Then
            Dim objAQL As New clsSampleNumAQL
            Dim rdChecknum As Integer = 0
            Dim NGNum_DEF As Integer
            Dim dt As DataTable
            Dim objDbLotInfo As New clsDbLotInfo

            'Group IDの全部組立LOTの投入数の合計と頻度でAQL検索
            dt = objAQL.selectAQLValue(objDbLotInfo.getSumLotInvnum(IcTag.szDifLotNo), dtmst.Rows(0)("CHECKFREQ"))
            If dt.Rows.Count > 0 Then
                rdChecknum = dt.Rows(0)("CheckNum")
                NGNum_DEF = dt.Rows(0)("ngNum")
                If strDP_CNT.Equals("0") = False Then
                    frameCount = Math.Ceiling(dt.Rows(0)("CheckNum") / CInt(strDP_CNT))
                End If
                objRCHistory.insertData(IcTag.szLotNo, IcTag.szProcsCD, IcTag.container1, lblEquipID.Text, txtOptNoStt.Text, IcTag.iInput, rdChecknum, frameCount, NGNum_DEF, 0, "", RC_TYPE)
                'setRandCheckInfo("LOT：" & IcTag.szLotNo)

            End If
        End If

        '記録削除
        If dtRecords.Rows.Count > 0 Then objRecords.deleteRecords(lblEquipID.Text)


    End Sub
    Protected Overrides Sub dontRandCheck(dtRecords As DataTable, ProdName As String, PKG As String, countNum As Integer)
        Dim objRecords As New clsRandCheckRecords

        '記録がある場合修正、If carFlg = CAR Then
        If dtRecords.Rows.Count = 0 Then
            objRecords.insertRecords(lblEquipID.Text, ProdName, PKG, countNum, IcTag.iInput)
        Else
            objRecords.updateRecords(lblEquipID.Text, dtRecords.Rows(0)("CountNum") + countNum, dtRecords.Rows(0)("SUMINVNUM") + IcTag.iInput)
        End If

    End Sub
    Overrides Sub totalCompAfter()
        If STS_SUCCESS.Equals(outHeader.Status) = False Then
            Exit Sub
        End If
        'If IsNothing(dtLot) = False AndAlso dtLot.Rows.Count >= 2 Then
        '    txtLotNo.Text = dtLot.Rows(1)(0)
        '    txtLotNo_KeyPress(txtLotNo, New KeyPressEventArgs(vbCr))
        '    'If dtLot.Rows.Count = 2 Then
        '    '    btnManual.PerformClick()
        '    '    setBeforeRackNo()
        '    'End If
        'Else
        If IsNothing(dtLot) = False AndAlso dtLot.Rows.Count >= 1 Then
            txtLotNo.Text = dtLot.Rows(0)(0)
            txtLotNo_KeyPress(txtLotNo, New KeyPressEventArgs(vbCr))
        End If
    End Sub
    Overrides Sub clsInfoAfter()
        '抜取り検査は未実行であれば、計上しない
        Dim objRCHistory As New clsRandCheckHistory
        Dim dtRCHistory As DataTable
        dtRCHistory = objRCHistory.selectRandCheckHistory(IcTag.szLotNo, IcTag.szProcsCD, lblEquipID.Text, "", "")
        If IsNothing(dtRCHistory) = False AndAlso dtRCHistory.Rows.Count <> 0 Then
            If DBNullTOblank(dtRCHistory.Rows(0)("STATUS")) = "" Then
                'MsgBox(getMsgStr("MSG10053"))
                Dim frm1 As New frmRandomInspection
                '抜け取り検査画面を呼出
                frm1.ShowDialog()

            End If
        End If

    End Sub
    Public Overrides Function doAProcMoveIn() As Object
        Return True
    End Function
    Public Overrides Sub setEmptyChips()
        If m_szFrameid_comp = 1 And IcTag.iFrameIDUse = 1 Then
            Dim frameinfo = getFrameInfo()
            If IsNothing(frameinfo) Then
                HideCommandWaiting()
                CommandFailed()
                Exit Sub
            End If

            lblEmptyChipsCnt.Text = frameinfo("vacantPcbCnt").ToString '空チップ数 

            'lblPcbCnt.Text = Val(frameinfo("frameCnt").ToString())
            'lblCrossCnt.Text = Val(frameinfo("totalCrossCnt").ToString())
            'lblCrossPcbCnt.Text = Val(frameinfo("crossPcbCnt").ToString())
            'lblFailedCnt.Text = Val(frameinfo("totalNgCnt").ToString())
            'lblCompleteCnt.Text = Val(frameinfo("totalOkCnt").ToString())

            Me.Refresh()
        End If

    End Sub
    Public Overrides Sub updateRackInfo()
        Dim rackNo As New ArrayList
        Dim dbLot As New clsDbLotDefect
        If txt1002.Text <> "" Then
            rackNo.Add(txt1002.Text)
        End If
        If txt1003.Text <> "" Then
            rackNo.Add(txt1003.Text)
        End If
        If txt1004.Text <> "" Then
            rackNo.Add(txt1004.Text)
        End If
        If txt1005.Text <> "" Then
            rackNo.Add(txt1005.Text)
        End If
        If txt1006.Text <> "" Then
            rackNo.Add(txt1006.Text)
        End If
        dbLot.DelInsRackInfo(IcTag.szLotNo, rackNo)
    End Sub

    Overrides Sub setProcessingLot()

    End Sub
    Protected Overrides Function lcFrmNum() As String
        Dim rtn As String
        If lblPcbCnt.Text <> "" Then
            rtn = lblPcbCnt.Text
        Else
            rtn = lblInputFrm.Text
        End If
        Return rtn
    End Function
    'DB的LC照合准备OK后，去掉下面的注释
    Overrides Function getLCPackage() As String 'add miaojf 2020/8/12 ver.60
        If CUSTOMIZES_DB_LC = True Then
            '①的取得
            Dim aimsCon As New clsAIMSOdbcDbIf

            pkgFLG = 1
            '②的取得
            Dim WAFERSIZE As String = ""
            Dim WAFERNAME As String = ""
            Dim mobjInParam As New DFlowService.InProcessCondition
            Dim mobjOutParam As New DFlowService.OutProcessCondition
            Dim Txn As New DFlowService.MFlowService

            Dim InHeader As New DFlowService.InHeader
            mobjInParam.Header = InHeader
            mobjInParam.Header.Client = "416301" ' 切替システムのCLIENTです
            dtJyokenData.DefaultView.RowFilter = "KOTEI = 'LOTINFO' and KOMOKUNAME = 'PRODUCT NAME'"
            mobjInParam.ProductName = dtJyokenData.DefaultView.Item(0)("KOMOKUDATA").ToString

            Dim pcData() As DFlowService.ProcessConditionData
            '③の取得
            mobjOutParam = Txn.ProcessConditionService_List(mobjInParam) '查询
            Dim outHeader As New DFlowService.OutHeader()
            If (mobjOutParam.Header.Status = "SUCCESS") Then

                pcData = mobjOutParam.ProcessConditionList

                For i As Integer = 0 To pcData.Length - 1
                    If pcData(i).Rudf = "RUDF242" Then
                        WAFERSIZE = pcData(i).Value
                    End If
                    If pcData(i).Rudf = "RUDF239" Then
                        WAFERNAME = pcData(i).Value
                    End If

                Next

            End If

            dtJyokenData.DefaultView.RowFilter = "KOTEI = 'LOTINFO' and KOMOKUNAME = 'PB LAYOUT'"

            Dim PKGARY() As String = dtJyokenData.DefaultView.Item(0)("KOMOKUDATA").ToString.Split("-")
            Dim pkgLen As String = 0
            Dim pkg As String = ""
            If PKGARY.Length > 2 Then
                pkgLen = PKGARY.Length - 2
            End If

            For i As Integer = 0 To pkgLen
                pkg &= PKGARY(i) & "-"
            Next
            pkg = pkg.Substring(0, pkg.Length - 1)

            '4的取得
            Dim PaiSheng As String = ""
            Dim WTKEYNO As String = ""
            Dim param As InSiteWebService.InViewLot = New InSiteWebService.InViewLot()
            param.Name = lotNo
            Dim clientStr As String = m_cEquipMat.GetBsiteClientString("S41")
            Dim viewLotServiceInfo As InSiteWebService.OutLotStd = mdl_ViewLotService.ViewLotServiceGet(param, clientStr)
            If Not IsNothing(viewLotServiceInfo) AndAlso STS_SUCCESS.Equals(viewLotServiceInfo.Header.Status) Then
                PaiSheng = viewLotServiceInfo.LotInf.Udf3.PadRight(20, "").Substring(16, 4).Trim()
                WTKEYNO = viewLotServiceInfo.LotInf.WaferLotID
            End If
            PaiSheng = PaiSheng.Replace(vbNullChar, "")
            If WAFERNAME.Substring(WAFERNAME.Length - 4, 4) = "HS-E" And PaiSheng.Length = 0 Then
                PaiSheng = "HS-E"
            End If
            Dim str As String = WAFERSIZE & "-" & pkg

            If PaiSheng <> "" Then
                str &= "-" & PaiSheng
            End If

            '1
            Dim sk As String = ""
            If WTKEYNO <> "" Then
                Dim a As New InkLessService.InkLessServiceClient
                Dim b As InkLessService.InkLessInfo
                b = a.FindSingle("WTKEYNO= '" & WTKEYNO & "'")

                If IsNothing(b) Then
                    sk = "K"
                    lblINK.Text = "INK品"
                    lblINK.ForeColor = Color.White
                End If

                If IsNothing(b) = False Then
                    sk = "S"
                    lblINK.Text = "INKLESS品"
                    lblINK.ForeColor = Color.Red
                End If

                sk &= "-"
            End If

            Dim strlc As String = ""
            If m_EquipInstPattern <> "00" Then
                strlc = m_cEquipMat.getEQUIP_SERIES(lblEquipID.Text, sk & str)
            Else
                strlc = sk & str
            End If

            Return strlc
        Else
            'Return lblShape.Text
            MyBase.getLCPackage()
        End If


    End Function

    Private Sub txt0103_TextChanged(sender As Object, e As EventArgs) Handles txt0103.TextChanged

    End Sub
End Class
